class Player
  def play_turn(warrior)
	directions = [:left,:forward,:right,:backward]
	if warrior.listen.size > 0
		if warrior.feel(:right).enemy? && warrior.feel(:forward).enemy?
			warrior.bind!(:right)
		elsif warrior.feel(:forward).enemy?
			warrior.attack!(:forward)
		elsif warrior.health < 19 && !warrior.feel(:right).enemy? && warrior.listen.size == 2
			warrior.rest!
		elsif warrior.listen.size == 2
			warrior.attack!(:right)
		else
			directions.each{|dir|
				if warrior.feel(dir).enemy?
					warrior.attack!(dir)
					break
				elsif warrior.feel(dir).captive?
					warrior.rescue!(dir)
					break
				elsif !warrior.feel(dir).stairs? && warrior.feel(dir).empty?
					warrior.walk!(dir)
					break
				end
				}
		end
	else
			warrior.walk!(warrior.direction_of_stairs)
	end
  end
 end
